﻿<UserControl x:Class="ClientCenter.Controls.AdvertisementGrid"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500"
             xmlns:custom="clr-namespace:ClientCenter.Controls">
    <UserControl.Resources>
        <custom:ImageConverter x:Key="ImageConverter" />
        <custom:StatusConverter x:Key="StatusConverter" />
    </UserControl.Resources>
    <Grid>
        <DockPanel>
            <DockPanel DockPanel.Dock="Top"  Height="32">
                <ToolBar Name="toolBar1">
                    <Button ToolTip="Reload assigned Packages" Name="bt_Reload" Click="bt_Reload_Click">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/SCCMCliCtrWPF;component/Images/shell32.dll_I0017_0409.ico"/>
                            <TextBlock Margin="2,0,0,0">Reload Advertisements</TextBlock>
                        </StackPanel>
                    </Button>
                    <Separator />
                    <Button ToolTip="Reload installation Status" Name="bt_ReloadStatus" Click="bt_ReloadStatus_Click">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/SCCMCliCtrWPF;component/Images/shell32.dll_I0017_0409.ico"/>
                            <TextBlock Margin="2,0,0,0">Load Status</TextBlock>
                        </StackPanel>
                    </Button>
                    <Separator />
                    <Button ToolTip="Hide Advertisements linked with a TS" Name="bt_Filter">
                        <StackPanel Orientation="Horizontal">
                            <CheckBox Name="cb_TSAdv" IsChecked="True" Checked="cb_TSAdv_Checked" Unchecked="cb_TSAdv_Unchecked">Hide TS Advertisements</CheckBox>
                        </StackPanel>
                    </Button>
                </ToolBar>
            </DockPanel>
            <DockPanel>
                <Grid>
                    <Grid.ColumnDefinitions >
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <ScrollViewer Grid.Row="0" Name="ScrollViewer1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
                        <DataGrid AutoGenerateColumns="False" HorizontalAlignment="Stretch" Name="dataGrid1" VerticalAlignment="Stretch" IsReadOnly="True" SelectionChanged="dataGrid1_SelectionChanged" Grid.Row="0">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="AdvID" Binding="{Binding Path=ADV_AdvertisementID}"/>
                                <DataGridTextColumn Header="PkgID" Binding="{Binding Path=PKG_PackageID}"/>
                                <DataGridTextColumn Header="Name" Binding="{Binding Path=PKG_Name}" SortDirection="Ascending" CanUserResize="True" />
                                <DataGridTextColumn Header="Manufacturer" Binding="{Binding Path=PKG_Manufacturer}" CanUserResize="True" />
                                <DataGridTextColumn Header="Version" Binding="{Binding Path=PKG_version}" SortDirection="Ascending" CanUserResize="True" />
                                <DataGridTextColumn Header="SourceVersion" Binding="{Binding Path=PKG_SourceVersion}" CanUserResize="True" />
                                <DataGridTextColumn Header="Language" Binding="{Binding Path=PKG_Language}"/>
                                <DataGridTextColumn Header="Program" Binding="{Binding Path=PRG_ProgramName}"/>
                                <DataGridTextColumn Header="CMD" Binding="{Binding Path=PRG_CommandLine}"/>
                                <DataGridTemplateColumn Header="" IsReadOnly="True" CanUserReorder="False" CanUserResize="False" CanUserSort="False" DisplayIndex="0">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Image Name="img" Source="/SCCMCliCtrWPF;component/Images/msi.ico" Height="16"></Image>
                                            <DataTemplate.Triggers>
                                                <DataTrigger Binding="{Binding PRG_ProgramID}" Value="*">
                                                    <Setter TargetName="img" Property="Source" Value="/SCCMCliCtrWPF;component/Images/Icon065.ico"/>
                                                </DataTrigger>
                                            </DataTemplate.Triggers>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                                <DataGridTemplateColumn Header="Status" IsReadOnly="True" CanUserReorder="False" CanUserResize="False" CanUserSort="False" DisplayIndex="1">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <!--<Image Source="{Binding Path=PKG_PackageID , Converter={StaticResource StatusConverter}, ConverterParameter=PRG_ProgramName}"/>-->
                                            <Image Height="16">
                                                <Image.Source>
                                                    <MultiBinding Converter="{StaticResource StatusConverter}">
                                                        <Binding Path="PKG_PackageID" />
                                                        <Binding Path="PRG_ProgramName" />
                                                        <Binding Path="ADV_AdvertisementID" />
                                                    </MultiBinding>
                                                </Image.Source>
                                            </Image>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                            <DataGrid.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Name="miInstallApp" Header="ReRun Advertisement" Click="miInstallApp_Click">
                                        <MenuItem.Icon>
                                            <Image Source="/SCCMCliCtrWPF;component/Images/Play.ico" Height="24" />
                                        </MenuItem.Icon>
                                    </MenuItem>
                                </ContextMenu>
                            </DataGrid.ContextMenu>
                        </DataGrid>
                    </ScrollViewer>
                    <GridSplitter ResizeDirection="Rows" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Width="Auto" Height="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" Background="#FF779CBA" />
                    <!--<ScrollViewer Grid.Row="2" Name="ScrollViewer2" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">-->
                    <DataGrid AutoGenerateColumns="False" HorizontalAlignment="Stretch" Name="dataGrid2" VerticalAlignment="Stretch" IsReadOnly="False" SelectionUnit="CellOrRowHeader" Grid.Row="2" CellEditEnding="dataGrid2_CellEditEnding">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Type" Binding="{Binding Path=TypeName}"/>
                            <DataGridTextColumn Header="Property" Binding="{Binding Path=Property}" SortDirection="Ascending"/>
                            <DataGridTextColumn Header="Value" Binding="{Binding Path=Value}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <!--</ScrollViewer>-->
                </Grid>

            </DockPanel>
        </DockPanel>
    </Grid>
</UserControl>
